stringpicture.htmlHTMLudog:MπùΔ§πùΔ§ÅÅ√ Monkeybread Realbasic plugin - Documentation - String-Picture

MBS Plugin Documentation

This is the documentation for the Realbasic Plugins from Monkeybreadsoftware.de. You find these plugins and the newest version of this document at http://www.monkeybreadsoftware.de/realbasic inside the plugins section.

This help was last updated on Freitag, 6. September 2002 and covers 2136 items: 126 classes, 2 controls and 583 global functions.

The list of the themes Global methods by category Global methods by name The list of the classes The list of the controls

BinaryStringtoPicture(data as String) as Picture

global method, Graphics & Pictures Fr, 30. Aug 2002
Mac OS Classic: Works Mac OS Carbon: Works Windows: Works
Function: Creates the picture back from the binary data inside the string.
Example: p=BinaryStringtoPicture(data)
Notes:
The format of the binary encoded picture data:

+ 0 Kenn, PPIC for Packed Picture
+ 4 Length of whole block
+ 8 Width (BigEndian)
+12 Height (BigEndian)
+16 Depth (BigEndian, 32 for 32bit)
+20 Offset of the binary data. maybe 40.
+24 Reserved for future use. Should be 0.
+40 Pixel Data, packed R, G, B in one byte per Subpixel.

300x300 Pixels will make up 300*300+40 -> 270040 Bytes.

This method does not require Quicktime or any other OS Service, but it does no compression. Currently limited to 32bit pictures made with NewPicture in Realbasic.

You may use the function picture.bitmap to make sure that the picture is a bitmap, because this function works only for bitmap pictures.

May be a good way to store pictures crossplatform inside a database. As Valentina can do it's own Zip based compression, this may be a wonderfull way to store pictures uncompressed (or loosless compressed) inside the database.

JPEGStringToPicture(buf as string[,allowdamaged as Boolean]) as picture

global method, Storing pictures Mo, 15. Jul 2002
Mac OS Classic: Works. Mac OS Carbon: Works. Windows: Works.
Function: Reads a picture from a JPEG file.
Notes:
This methods should read all JPEG file data you can get, but I've only tested it for 32 bit color and 8 bit grayscale.

This method is not depending on any library! It works without QuickTime even on System 7, but as it contains everything needed this method is around 120 KB big!
(REALbasic's OpenAsPicture depends on QuickTime)

I wrote it mainly because Realbasic's built in OpenAsJPEG code crashes badly if your picture is not full downloaded. For example if you have a webbrowser you can now show JPEGs while you download them. Normally you can see a good picture allready with 50% of the data.

REALbasic's OpenAsPicture in contrast crashes if the picture is not 100% downloaded or instead of a crash you get a white picture.

See the "JPEGToString example", "jpeg load crashtest" and "SaveJPEG without QuickTime" examples.

PicturetoBinaryString(p as picture) as string

global method, Graphics & Pictures Fr, 30. Aug 2002
Mac OS Classic: Works Mac OS Carbon: Works Windows: Works
Function: Creates a string with the picture content for saving.
Example: s=PicturetoBinaryString(pic)
Notes:
The format of the binary encoded picture data:

+ 0 Kenn, PPIC for Packed Picture
+ 4 Length of whole block
+ 8 Width (BigEndian)
+12 Height (BigEndian)
+16 Depth (BigEndian, 32 for 32bit)
+20 Offset of the binary data. maybe 40.
+24 Reserved for future use. Should be 0.
+40 Pixel Data, packed R, G, B in one byte per Subpixel.

300x300 Pixels will make up 300*300+40 -> 270040 Bytes.

This method does not require Quicktime or any other OS Service, but it does no compression. Currently limited to 32bit pictures made with NewPicture in Realbasic.

You may use the function picture.bitmap to make sure that the picture is a bitmap, because this function works only for bitmap pictures.

May be a good way to store pictures crossplatform inside a database. As Valentina can do it's own Zip based compression, this may be a wonderfull way to store pictures uncompressed (or loosless compressed) inside the database.

PictureToJPEGString(pic as picture,quality as integer) as string

global method, Storing pictures Mi, 31. Jul 2002
Mac OS Classic: Works. Mac OS Carbon: Works. Windows: Works.
Function: Saves a picture into a string using JPEG compression.
Notes:
This methods saves 32bit pictures to a file using JPEG Compression. Using the parameter you can specify the quality in range between 25 and 100%

This method is not depending on any library! It works without QuickTime even on System 7, but as it contains everything needed this method is around 100 KB big!
(REALbasic's SaveAsJPEG depends on QuickTime)

You may use the function picture.bitmap to make sure that the picture is a bitmap, because this function works only for bitmap pictures.

Improved for RB 4.5 on Windows to work better by not flipping the image randomly.

See the "JPEGToString example" and "SaveJPEG without QuickTime" examples.

PicturetoString(p as picture,codec as string,quality as integer,depth as integer) as string

global method, Graphics & Pictures Fr, 30. Aug 2002
Mac OS Classic: Works Mac OS Carbon: Works Windows: Works
Function: QuickTime will make a string from the picture using the specified codec.
Example: s=PictureToString(pic,"jpeg",512,0)
Notes:
p as picture:
Your picture must be a pixel bitmap or in other words a picture made using newpicture. You can check it using the graphics property or just use a function like that to verify that your picture is well:

Function MakeGoodPicture(old as picture) As picture
dim p as picture

p=old
if p<>nil and old.graphics=nil then
p=newpicture(old.width,old.height,32)
p.graphics.drawpicture old,0,0
end if

return p
End Function

codec as string:
The codec is a 4 letter code to determinate the codec to use. Possible values for QuickTime 5.0, which I've tested:

"jpeg",
"gif ",
"png ",
"tiff",
"tga ".

quality as integer
Any value between 0 and &h400 to indicate the quality:

&h000Min Quality
&h100Low Quality
&h200Normal Quality
&h300High Quality
&h3FFMax Quality
&h400Loosless Quality

depth as integer

The depth at which the image is likely to be viewed. Compressors may use this as an indication of the color or grayscale resolution of the compressed image. If you set this parameter to 0, the Image Compression Manager determines the appropriate value for the source image. Values of 1, 2, 4, 8, 16, 24, and 32 indicate the number of bits per pixel for color images. Values of 34, 36, and 40 indicate 2-bit, 4-bit, and 8-bit grayscale, respectively, for grayscale images.


Improved for RB 4.5 on Windows to work better by not flipping the image randomly.

You may use the function picture.bitmap to make sure that the picture is a bitmap, because this function works only for bitmap pictures.

This function requires QuickTime 3.0 or newer!

StringtoPicture(data as String, FileName as String, MimeType as String) as Picture

global method, Graphics & Pictures Fr, 30. Aug 2002
Mac OS Classic: Works Mac OS Carbon: Works Windows: Works
Function: QuickTime will make a picture object from the provided data string (e.g. a downloaded jpeg file from the Internet) and make a picture object from it. To make it faster provide a filename or MimeType so QuickTime will work faster.
Example: p=StringtoPicture(data,"mypicture.jpg","Image/jpeg")
Notes:
This function is based on the source code from Stephan Huber http://www.digitalmind.de/realbasic. I added it to extend it for Windows and add the inverse function.

You may use the function picture.bitmap to make sure that the picture is a bitmap, because this function works only for bitmap pictures.

This function requires QuickTime 3.0 or newer!

StringtoPictureByOSType(data as String, OSType as String) as Picture

global method, Graphics & Pictures Fr, 30. Aug 2002
Mac OS Classic: Works Mac OS Carbon: Works Windows: Works
Function: QuickTime will make a picture object from the provided data string (e.g. a downloaded jpeg file from the Internet) and make a picture object from it. To make it faster provide a filename or MimeType so QuickTime will work faster.
Example: p=StringtoPictureByOSType(data,"JPEG")
Notes:
This function is based on the source code from Stephan Huber http://www.digitalmind.de/realbasic. I added it to extend it for Windows and add the inverse function.

You may use the function picture.bitmap to make sure that the picture is a bitmap, because this function works only for bitmap pictures.

The OSType is the same type like in mactype of a folderitem.

Contact

Written 2002 by Christian Schmitz. Feel free to ask or report mistakes to realbasic@macsw.de.
Thanks.

This resource fork intentionally left blank ˇˇ